import { RobCityStepPanelBase } from "../RobCityStepPanelBase";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Language } from "../../../../../extend/language/Language";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ItemsBox } from "../../common/item/ItemsBox";
import { CopyConfig } from "../../../resource/CopyConfig";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { RuleExplainButton } from "../../common/button/RuleExplainButton";
import { RobCityStepThreeGuildItem } from "./RobCityStepThreeGuildItem";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ECopyType } from "../../../../../Message/Public/ECopyType";
import { SRobCityThreeJoinTeam } from "../../../../../Message/Public/SRobCityThreeJoinTeam";
import { Cache } from "../../../cache/Cache";
import { ClockManager } from "../../../manager/ClockManager";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { SecTimerView } from "../../common/SecTimerView";
type int = number;
//class RobCityStepThreePanel
    
    export  class RobCityStepThreePanel extends RobCityStepPanelBase
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            var loc2=null;
            var loc4=null;
            ObjCreate.createBg(0, 0, 804, 160, this);
            ObjCreate.createGImageBitmap(ImagesConst.RobCityBg2, 1, 2, this);
            ObjCreate.createBg(0, 163, 804, 223, this);
            ObjCreate.createGImageBitmap(ImagesConst.RobCityBg3, 1, 165, this);
            this._enterBtn = ObjCreate.createGLoadedButton(ResFileConst.RobCityEnterCopyBtn, 352, 50, 100, 33, this);
            this._enterBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onEnterBtnClickHandler);
            this._enterBtn.enabled = false;
            var loc1=GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat5);
            this._tipLabel = ObjCreate.createGTextField("", 200, 92, 404, 20, this, loc1, false);
            this._tipLabel.htmlText = Language.getString(60940);
            this._countDown = ObjCreate.createSecTimeView("", 200, 115, 404, 20, this, loc1);
            this._countDown.filters = [FilterConst.glowFilter];
            this._countDown.mouseEnabled = false;
            loc2 = new ItemsBox();
            loc2.x = 58;
            loc2.y = 114;
            loc2.setItems(CopyConfig.instance.getRobCopyRewards(4));
            this.addChild(loc2);
            var loc3=new ItemsBox();
            loc3.x = 622;
            loc3.y = 114;
            loc3.setItems(CopyConfig.instance.getRobCopyRewards(5));
            this.addChild(loc3);
            this._resSp = new Object /* flash.display.Sprite */();
            this.addChild(this._resSp);
            LoaderHelp.addResCallBack(ResFileConst.robCity, this.onResLoadedHandler);
            this._guildItemDic = new Map<any, any> /* flash.utils.Dictionary */();
            this.addGuildItem(0, 375, 203);
            this.addGuildItem(1, 70, 194);
            this.addGuildItem(2, 70, 286);
            this.addGuildItem(3, 640, 194);
            this.addGuildItem(4, 640, 286);
            (loc4 = new RuleExplainButton()).tooltipText = CopyConfig.instance.getRobCopyDesc(5);
            loc4.x = 490;
            loc4.y = 130;
            this.addChild(loc4);
            return;
        }

        /* internal  */onResLoadedHandler(): void
        {
            this._bg1 = ObjCreate.createBitmap(ImagesConst.RobCityItemBgUp, 20, 190, this._resSp);
            this._bg2 = ObjCreate.createBitmap(ImagesConst.RobCityItemBgUp, 20, 282, this._resSp);
            this._bg3 = ObjCreate.createBitmap(ImagesConst.RobCityItemBgUp, 590, 190, this._resSp);
            this._bg4 = ObjCreate.createBitmap(ImagesConst.RobCityItemBgUp, 590, 282, this._resSp);
            ObjCreate.createBitmap(ImagesConst.RobCityNum1, 30, 205, this._resSp);
            ObjCreate.createBitmap(ImagesConst.RobCityNum2, 30, 297, this._resSp);
            ObjCreate.createBitmap(ImagesConst.RobCityNum3, 600, 205, this._resSp);
            ObjCreate.createBitmap(ImagesConst.RobCityNum4, 600, 297, this._resSp);
            return;
        }

        /* internal  */addGuildItem(arg1: int, arg2: int, arg3: int): void
        {
            var loc1=null;
            (loc1 = new RobCityStepThreeGuildItem()).x = arg2;
            loc1.y = arg3;
            this.addChild(loc1);
            this._guildItemDic[arg1] = loc1;
            return;
        }

        /* internal  */onEnterBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RobCity_doEnterCopy, ECopyType._ECopyRobCityThree));
            return;
        }

        public updateTeamInfos(arg1: SRobCityThreeJoinTeam, arg2: SRobCityThreeJoinTeam, arg3: SRobCityThreeJoinTeam, arg4: SRobCityThreeJoinTeam, arg5: SRobCityThreeJoinTeam): void
        {
            (this._guildItemDic[0] as RobCityStepThreeGuildItem).updateInfo(arg1);
            (this._guildItemDic[1] as RobCityStepThreeGuildItem).updateInfo(arg2);
            (this._guildItemDic[2] as RobCityStepThreeGuildItem).updateInfo(arg3);
            (this._guildItemDic[3] as RobCityStepThreeGuildItem).updateInfo(arg4);
            (this._guildItemDic[4] as RobCityStepThreeGuildItem).updateInfo(arg5);
            return;
        }

        public updateStartInfo(): void
        {
            var loc2=0;
            var loc1=Cache.instance.robCity.robCityCopyThreeStartInfo;
            if (Cache.instance.robCity.robCityCopyThreeStarted && loc1) 
            {
                this._enterBtn.enabled = true;
                this._countDown.stop();
                this._countDown.htmlText = Language.getString(27028);
                this._tipLabel.htmlText = Language.getStringByParam(60957, loc1.startDt.hours, loc1.startDt.minutes);
            }
            else if (loc1) 
            {
                loc2 = (loc1.startDt.time - ClockManager.instance.nowDate.time) / 1000;
                loc2 = loc2 < 0 ? 0 : loc2;
                this._countDown.setParse(Language.getStringByParam(60941, "hh: mm: ss"));
                this._countDown.setLeftTime(loc2);
                this._enterBtn.enabled = true;
                this._tipLabel.htmlText = Language.getStringByParam(60956, loc1.startDt.hours, loc1.startDt.minutes);
            }
            else 
            {
                this._countDown.stop();
                this._countDown.htmlText = Language.getString(41619);
                this._enterBtn.enabled = false;
                if (Cache.instance.crossCityIncome.getIsDoubleWeek()) 
                {
                    this._tipLabel.htmlText = Language.getString(60990);
                }
                else 
                {
                    this._tipLabel.htmlText = Language.getString(60989);
                }
            }
            return;
        }

        /* internal */ /* var */_resSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_enterBtn: GLoadedButton;

        /* internal */ /* var */_tipLabel: GTextFiled;

        /* internal */ /* var */_countDown: SecTimerView;

        /* internal */ /* var */_guildItemDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_bg1: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bg2: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bg3: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bg4: Object /* flash.display.Bitmap */;
    }
